#include <stdio.h>
#include "Syscall.h"
#include "System.h"

/// <summary>
/// The GetMachineName
/// function retrieves host information
/// corresponding to a host name
/// from a host database.
/// </summary>
int GetMachineName(char *name, int len)
{
	return 0;
}

/// <summary>
/// The SetMachineName
/// function retrieves host information
/// corresponding to a host name
/// from a host database.
/// </summary>
int SetMachineName(const wchar_t *name, int len)
{
	if (name == NULL)
		return SYS_ERROR;

	if (GetGroupID() > 0)
		return SYS_NOACCESS;

	if (Syscall2(__NR_sethostname, (int)name, len) < 0)
		return SYS_ERROR;

	return SYS_OK;
}

/// <summary>
/// The GetDomainName
/// function retrieves host information
/// corresponding to a host name
/// from a host database.
/// </summary>
int GetDomainName(char *name, int len)
{
	return 0;
}

/// <summary>
/// The SetDomainName
/// function retrieves host information
/// corresponding to a host name
/// from a host database.
/// </summary>
int SetDomainName(const char *name, int len)
{
	if (name == NULL)
		return SYS_ERROR;

	if (GetGroupID() > 0)
		return SYS_NOACCESS;

	if (Syscall2(__NR_setdomainname, (int)name, len) < 0)
		return SYS_ERROR;

	return SYS_OK;
}

/// <summary>
/// The Restart function
/// retrieves host information
/// corresponding to a host name
/// from a host database.
/// </summary>
int Restart(void)
{
	if (Syscall0(__NR_restart_syscall) < 0)
		return -1;
	return 0;
}

/// <summary>
/// The Reboot function
/// retrieves host information
/// corresponding to a host name
/// from a host database.
/// </summary>
int Reboot(void)
{
	if (Syscall0(__NR_reboot) < 0)
		return -1;
	return 0;
}
